package team.zero.lemon.module.message.service;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import team.zero.lemon.common.exception.CustomException;
import team.zero.lemon.common.service.CrudService;
import team.zero.lemon.common.persistence.Page;
import team.zero.lemon.module.message.dao.IMessageActionDao;
import team.zero.lemon.module.message.entity.Message;
import team.zero.lemon.module.message.entity.MessageAction;

import java.util.List;

/**
 * Created by fangpingxi on 2016/11/11.
 */
@Service
public class MessageActionService extends CrudService<IMessageActionDao, MessageAction> {

    public List<MessageAction> getMessageActionByMessageId(Integer messageId) {
        try {
            return dao.getMessageActionByMessageId(messageId);
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }

    public Page<MessageAction> getReceivingPage(MessageAction messageAction) {
        try {
            messageAction.page.setList(dao.getReceivingPage(messageAction));
            return messageAction.page;
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }

    public Page<MessageAction> getSendingPage(MessageAction messageAction) {
        try {
            messageAction.page.setList(dao.getSendingPage(messageAction));
            return messageAction.page;
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }

    public Page<MessageAction> getGarbagingPage(MessageAction messageAction) {
        try {
            messageAction.page.setList(dao.getGarbagingPage(messageAction));
            return messageAction.page;
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }

    public int deleteAction(MessageAction messageAction) {
        try {
            return dao.deleteAction(messageAction);
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }

    public int update(MessageAction messageAction) {
        try {
            return dao.update(messageAction);
        } catch (Exception e) {
            throw new CustomException(e);
        }

    }
}
